package com.czkevin.cif.enchantments;

import de.tr7zw.nbtapi.NBTCompound;

public class EnchantmentInstance {

  public final Enchantment type;

  public final int level;

  public EnchantmentInstance(Enchantment type, int level) {
    this.type = type;
    this.level = level;
  }

  @Override
  public String toString() {
    return String.format("%s lv.%s", type.getDisplayName(), level);
  }

  @Override
  public int hashCode() {
    return type.key().hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if(obj == null || !EnchantmentInstance.class.isAssignableFrom(obj.getClass())) {
      return false;
    }
    return ((EnchantmentInstance) obj).type == this.type;
  }

}
